// 统一对组件类进行处理,在组件销毁前,要保证清除定时器
export function inject_component_will_unmount(target: any) {

  const next = target.prototype.componentWillUnmount

  target.prototype.componentWillUnmount = function () {
    if (next) next.call(this, ...arguments)
    this.unmount = true
  }

  const setState = target.prototype.setState

  target.prototype.setState = function () {
    if (this.unmount) return
    setState.call(this, ...arguments)
  }
}
